home *** CD-ROM | disk | FTP | other *** search
/ APDL Eductation Resources / APDL Eductation Resources.iso / programs / electronic / rlab / TestMatrix / poisson_r < prev    next >
Encoding:
Text File  |  1994-12-20  |  954 b   |  37 lines

  1. //-------------------------------------------------------------------//
  2.  
  3. // Synopsis:    Block tridiagonal matrix from Poisson's equation.
  4.  
  5. // Syntax:    A = poisson ( N )
  6.  
  7. // Dexcription:
  8.  
  9. //    A  is the block tridiagonal matrix of order N^2 resulting from
  10. //    discretizing Poisson's equation with the 5-point operator on
  11. //    an N-by-N mesh.  
  12.  
  13. //      Reference:
  14. //       G.H. Golub and C.F. Van Loan, Matrix Computations, second edition,
  15. //       Johns Hopkins University Press, Baltimore, Maryland, 1989
  16. //       (Section 4.5.4).
  17.  
  18. //    This file is a translation of poisson.m from version 2.0 of
  19. //    "The Test Matrix Toolbox for Matlab", described in Numerical
  20. //    Analysis Report No. 237, December 1993, by N. J. Higham.
  21.  
  22. // Dependencies
  23.    require tridiag kron
  24.  
  25. //-------------------------------------------------------------------//
  26.  
  27. poisson = function ( n )
  28. {
  29.   local (n)
  30.  
  31.   S = tridiag(n,-1,2,-1);
  32.   I = eye(n,n);
  33.   A = kron(I,S) + kron(S,I);
  34.  
  35.   return A;
  36. };
  37.